package com.hyt.it.ogt.kq.service.bm.api;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hyt.common.apiInfor.ApiResponse;
import com.hyt.it.ogt.kq.service.bm.api.model.PtBmProjectVO;
import com.hyt.it.ogt.kq.service.bm.service.IProject2Service;
import com.hyt.it.ogt.kq.common.bm.utils.Constant;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiOperationSort;
import io.swagger.annotations.ApiSort;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Description:
 * @Author: STARF
 * @CreateDate: 2022/05/30 09:49
 **/
@RestController
@Api(tags = "26.平台接口Api", value = "平台接口Api")
@ApiSort(value = 26)
@RequestMapping("/bm/pt")
public class PtBmApi extends ApiBaseController {
    @Resource
    private IProject2Service iProject2Service;

    @ApiOperation(value = "26.1.1 平台获取报名基本信息列表(限制50条任务)", notes = "20000:成功",response = PtBmProjectVO.class)
    @ApiOperationSort(value = 1)
    @RequestMapping(value = "/ptQueryProjectNameList", method = RequestMethod.GET)
    public ApiResponse ptQueryProjectNameList(@RequestParam String officeId, @RequestParam(required = false) String projectName) {
        List<PtBmProjectVO> list = iProject2Service.ptQueryProjectNameList(officeId, projectName);
        return ApiResponse.builder().code(Constant.RESPONSE_CODE_SUCCESS).data(list).build();
    }

    @ApiOperation(value = "26.1.2 平台获取报名任务报考数据", notes = "20000:成功",response = PtBmProjectVO.class)
    @ApiOperationSort(value = 2)
    @RequestMapping(value = "/ptQueryProjectInfo", method = RequestMethod.GET)
    public ApiResponse<List<PtBmProjectVO>> ptQueryProjectInfo(@RequestParam String projectId) {
        List<PtBmProjectVO> list = iProject2Service.ptQueryProjectInfo(projectId);
        return ApiResponse.<List<PtBmProjectVO>>builder().code(Constant.RESPONSE_CODE_SUCCESS).data(list).build();
    }

    @ApiOperation(value = "26.1.3 平台获取报名任务报考信息列表(限制50条任务)", notes = "20000:成功",response = PtBmProjectVO.class)
    @ApiOperationSort(value = 3)
    @RequestMapping(value = "/ptQueryProjectList", method = RequestMethod.GET)
    public ApiResponse ptQueryProjectList(@RequestParam String officeId, @RequestParam(required = false) String projectName) {
        List<PtBmProjectVO> list = iProject2Service.ptQueryProjectList(officeId, projectName);
        return ApiResponse.builder().code(Constant.RESPONSE_CODE_SUCCESS).data(list).build();
    }

    @ApiOperation(value = "26.1.4 平台分页获取报名任务报考信息列表", notes = "20000:成功",response = PtBmProjectVO.class)
    @ApiOperationSort(value = 4)
    @RequestMapping(value = "/ptGetProjectPage", method = RequestMethod.POST)
    public ApiResponse<Page<PtBmProjectVO>> ptGetProjectPage(@RequestBody PtBmProjectVO vo) {
        Page<PtBmProjectVO> page = iProject2Service.ptGetProjectPage(vo);
        return ApiResponse.<Page<PtBmProjectVO>>builder().code(Constant.RESPONSE_CODE_SUCCESS).data(page).build();
    }

    @ApiOperation(value = "26.1.5 平台绑定/解绑报名任务, bangFlag：1-绑定，0-解绑(未绑定)", notes = "20000:成功")
    @ApiOperationSort(value = 5)
    @RequestMapping(value = "/ptBangProject", method = RequestMethod.GET)
    public ApiResponse ptBangProject(@RequestParam String projectId, @RequestParam Integer bangFlag) {
        Boolean flag = iProject2Service.ptBangProject(projectId, bangFlag);
        if (null == flag) {
            return ApiResponse.builder().code(Constant.RESPONSE_CODE_31010110).data(null).build();
        } else if (flag){
            return ApiResponse.builder().code(Constant.RESPONSE_CODE_SUCCESS).data(null).build();
        }
        return ApiResponse.builder().code(Constant.RESPONSE_CODE_31010101).data(null).build();
    }

}
